package io.renren.modules.map.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.map.entity.MaptableEntity;
import io.renren.modules.map.service.MaptableService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;


@RestController
@RequestMapping("map/maptable")
public class MaptableController {
    @Autowired
    private MaptableService maptableService;



    @GetMapping("/updatestatus")
    public int updatestatus(@RequestParam(value = "mapNo") String mapNo){
        return maptableService.updatestatus(mapNo);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("map:maptable:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = maptableService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{mapNo}")
    @RequiresPermissions("map:maptable:info")
    public R info(@PathVariable("mapNo") Integer mapNo){
		MaptableEntity maptable = maptableService.getById(mapNo);

        return R.ok().put("maptable", maptable);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("map:maptable:save")
    public R save(@RequestBody MaptableEntity maptable){
		maptableService.save(maptable);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("map:maptable:update")
    public R update(@RequestBody MaptableEntity maptable){
		maptableService.updateById(maptable);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("map:maptable:delete")
    public R delete(@RequestBody Integer[] mapNos){
		maptableService.removeByIds(Arrays.asList(mapNos));

        return R.ok();
    }

}
